package com.cutler.kelv.wordduel;

import javax.persistence.Id;

import org.json.JSONException;
import org.json.JSONObject;

import com.googlecode.objectify.annotation.Entity;

@Entity
public class UserInfo {

	public @Id String email;
	public String name;
	public String passwordHash;
	public boolean verified;
	public int pin;
	
	public UserInfo() { }

	
	@Override
	public String toString() {
		return toJSON().toString();
	}
	
	public JSONObject toJSON() {
		return toJSON(false);
	}
	
	public JSONObject toJSON(boolean withPin) {
		JSONObject jObject = new JSONObject();
		try {
			jObject.put("Name", name);
			jObject.put("Email", email);
			if (withPin) {
				jObject.put("Pin", pin);
			}
		} catch (JSONException e) {}
		return jObject;	
	}
}
